home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / Macintosh Tracker 1.1 Source / Tracker Server Folder / dump_song.c < prev    next >
Text File  |  1993-05-18  |  3KB  |  142 lines

  1. /* dump_song.c */
  2.  
  3. /* $Id: dump_song.c,v 3.4 1993/04/25 14:08:15 espie Exp espie $
  4.  * $Log: dump_song.c,v $
  5.  * Revision 3.4  1993/04/25  14:08:15  espie
  6.  * Added finetune display.
  7.  *
  8.  * Revision 3.3  1993/01/15  14:00:28  espie
  9.  * Added bg/fg test.
  10.  *
  11.  * Revision 3.2  1992/11/27  10:29:00  espie
  12.  * General cleanup
  13.  *
  14.  * Revision 3.1  1992/11/19  20:44:47  espie
  15.  * Protracker commands.
  16.  *
  17.  * Revision 3.0  1992/11/18  16:08:05  espie
  18.  * New release.
  19.  */
  20.  
  21. #include <malloc.h>
  22. #include <stdio.h>
  23. #include <string.h>
  24. #include <ctype.h>
  25.  
  26. #include "defs.h"
  27. #include "extern.h"
  28. #include "song.h"
  29. #include "channel.h"
  30.  
  31. LOCAL char *id = "$Id: dump_song.c,v 3.4 1993/04/25 14:08:15 espie Exp espie $";
  32.  
  33. /***
  34.  *
  35.  *  dump_block/dump_song:
  36.  *  shows most of the readable info
  37.  *  concerning a module on the screen.
  38.  *
  39.  ***/
  40.  
  41. LOCAL void dump_block(b)
  42. struct block *b;
  43.     {
  44.     int i, j;
  45.  
  46.     for (i = 0; i < BLOCK_LENGTH; i++)
  47.         {
  48.         for (j = 0; j < NUMBER_TRACKS; j++)
  49.             {
  50.             printf("%8d%5d%2d%4d", b->e[j][i].sample_number,
  51.                 b->e[j][i].pitch, b->e[j][i].effect,
  52.                 b->e[j][i].parameters);
  53.             }
  54.         printf("\n");
  55.         }
  56.     }
  57.  
  58. /* make_readable(s):
  59.  * transform s into a really readable string */
  60.  
  61. LOCAL void make_readable(s)
  62. char *s;
  63.     {
  64.     char *t, *orig;
  65.  
  66.     if (!s)
  67.         return;
  68.  
  69.     orig = s;
  70.     t = s;
  71.  
  72.         /* get rid of the st-xx: junk */
  73.     if (strncmp(s, "st-", 3) == 0 || strncmp(s, "ST-", 3) == 0)
  74.         {
  75.         if (isdigit(s[3]) && isdigit(s[4]) && s[5] == ':')
  76.             s += 6;
  77.         }
  78.     while (*s)
  79.         {
  80.         if (isprint(*s))
  81.             *t++ = *s;
  82.         s++;
  83.         }
  84.     *t = '\0';
  85.     while (t != orig && isspace(t[-1]))
  86.         *--t = '\0';
  87.     }
  88.  
  89. void dump_song(song)
  90. struct song *song;
  91.     {
  92.     int i, j;
  93.     int maxlen;
  94.     static char dummy[1];
  95.  
  96.     if (!run_in_fg())
  97.         return;
  98.     dummy[0] = '\0';
  99.     printf("%s\n", song->title);
  100.  
  101.     maxlen = 0;
  102.     for (i = 1; i < NUMBER_SAMPLES; i++)
  103.         {
  104.         if (!song->samples[i].name)
  105.             song->samples[i].name = dummy;
  106.         make_readable(song->samples[i].name);
  107.         if (maxlen < strlen(song->samples[i].name))
  108.             maxlen = strlen(song->samples[i].name);
  109.         }
  110.     for (i = 1; i < NUMBER_SAMPLES; i++)
  111.         {
  112.         if (song->samples[i].start || strlen(song->samples[i].name) > 2)
  113.             {
  114. #ifdef SHOW_SEQ
  115.             printf("%2d", i);
  116. #endif
  117.             printf("   %s", song->samples[i].name);
  118.             for (j = strlen(song->samples[i].name); j < maxlen + 2; j++)
  119.                 putchar(' ');
  120.             if (song->samples[i].start)
  121.                 {
  122.                 printf("%5d", song->samples[i].length);
  123.                 if (song->samples[i].rp_length > 2)
  124.                     {
  125.                     printf("(%5d %5d)", song->samples[i].rp_offset, 
  126.                         song->samples[i].rp_length);
  127.                     }
  128.                 else
  129.                     printf("             ");
  130.                 if (song->samples[i].volume != MAX_VOLUME)
  131.                     printf("%3d", song->samples[i].volume);
  132.                 else 
  133.                     printf("   ");
  134.                 if (song->samples[i].finetune)
  135.                     printf("%3d", song->samples[i].finetune);
  136.                 }
  137.             putchar('\n');
  138.             }
  139.         }
  140.     fflush(stdout);
  141.     }
  142.